package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.ProblemFeedbackApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class FeedbackAdapter extends AppAdapter<ProblemFeedbackApi.Bean> {
//    private ImgListAdapter adapter;
    public FeedbackAdapter(Context context) {
        super(context);
    }


    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvContent;
        private ShapeTextView mTvTime;
        private ShapeTextView mTvType;



        private ViewHolder() {
            super(R.layout.item_feedback);
            mTvContent = findViewById(R.id.tv_content);
            mTvTime = findViewById(R.id.tv_time);
            mTvType = findViewById(R.id.tv_type);
//            adapter = new ImgListAdapter(getContext());
        }

        @Override
        public void onBindView(int position) {
            mTvContent.setText(getItem(position).getContent());
            mTvTime.setText("反馈时间："+getItem(position).getReply_time());
            //0 代回复 1 已回复 2 已完成
            if (getItem(position).getStatus()==0){
                mTvType.setText("待回复");
                mTvType.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_F2BA00))
                        .intoTextColor();
            }else if (getItem(position).getStatus()==1){
                mTvType.setText("已回复");
                mTvType.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_F2BA00))
                        .intoTextColor();
            }else {
                mTvType.setText("已完成");
                mTvType.getTextColorBuilder()
                        .setTextColor(ContextCompat.getColor(getContext(), R.color.color_A5A5A5))
                        .intoTextColor();
            }
        }
    }
}